import request from '@/utils/request'
import requests from '@/utils/oaRequest'
export function login(data) {
  return requests({
    url: '/sys/login',
    method: 'post',
    data
  })
}
export const getCodeImage = (data) => requests({
  url: `/sys/randomImage/${data}`, method: "get"
})

///jeecg-boot/sys/position/list
export const positionlist = (data) => requests({
  url: `/sys/user/list`,
  methods: "get",
  data
})
//上传头像 http://localhost:8080/jeecg-boot/sys/common/upload
export const userImg = (data, params) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/common/upload`,
  method: "POST",
  data,//表单数据 （图片）
  params//携带参数
})
//校验核对/sys/duplicate/check
export const duplicatecheck = (data) => requests({
  url: `/sys/duplicate/check?tableName=${data.tableName}&fieldName=${data.fieldName}&fieldVal=${data.fieldVal}&dataId=${data.dataId}`,
  methods: "get",
  data
})
//校验核对/sys/duplicate/check
export const userduplicatecheck = (data) => requests({
  url: `/sys/duplicate/check?tableName=${data.tableName}&fieldName=${data.fieldName}&fieldVal=${data.fieldVal}&dataId=${data.dataId}`,
  methods: "get",
  data
})
//编辑用户/sys/user/edit
export const useredit = (data) => requests({
  url: `/sys/user/edit`,
  method: "PUT",
  data
})
//删除用户
export const userdelete = (data) => requests({
  url: `/sys/user/delete?id=${data.id}`,
  method: "DELETE",
  data
})
//批量删除用户/sys/user/deleteBatch
export const userdeleteBatch = (data) => requests({
  url: `/sys/user/deleteBatch?ids=${data.ids}`,
  method: "DELETE",
  data
})
//冻结用户/sys/user/frozenBatch
export const userfrozenBatch = (data) => requests({
  url: `/sys/user/frozenBatch`,
  method: "PUT",
  data
})
//改密码/sys/user/changePassword
export const changePassword = (data) => requests({
  url: `/sys/user/changePassword`,
  method: "PUT",
  data
})
//导出用户列表
export const userexportXls = (data) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/user/exportXls?_t=1664462232&column=createTime&order=desc&field=id,,,dictName,dictCode,description,action&pageNo=${data.pageNo}&pageSize=${data.pageSize}`,
  method: "GET",
  responseType: 'blob',
  data
})
//导出角色列表/sys/role/exportXls
export const roleexportXls = (data) => requests({
  url: `/sys/role/exportXls?pageNo=${data.pageNo}&pageSize=${data.pageSize}`,
  method: "GET",
  responseType: 'blob',
  data
})
//编辑角色列表/sys/role/edit
export const roleedit = (data) => requests({
  url: `/sys/role/edit`,
  method: "put",
  data
})
//删除角色/sys/role/delete
export const roledelete = (data) => requests({
  url: `/sys/role/delete?id=${data.id}`,
  method: "DELETE",
  data
})
//租户列表/sys/tenant/queryList //北京租户
export const tenantqueryList = (data) => requests({
  url: `/sys/tenant/queryList`,
  method: "GET",
  data
})
//添加租户接口/sys/tenant/add
export const tenantadd = (data) => requests({
  url: `/sys/tenant/add`,
  method: "POST",
  data
})
//编辑租户接口/sys/tenant/edit
export const tenantedit = (data) => requests({
  url: `/sys/tenant/edit`,
  method: "PUT",
  data
})
//删除用户接口/sys/tenant/delete
export const tenantdelete = (data) => requests({
  url: `/sys/tenant/delete?id=${data.id}`,
  method: "DELETE",
  data
})
// 删除用户接口http://localhost:8080/jeecg-boot/sys/user/deleteUserRole
export const userdeleteUserRole = (data) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/user/deleteUserRole?roleId=${data.roleId}&userId=${data.userId}`,
  method: "DELETE",
  data
})
//添加用户接口http://localhost:8080/jeecg-boot/sys/user/addSysUserRole
export const useraddSysUserRole = (data) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/user/addSysUserRole`,
  method: "POST",
  data
})
//批量删除用户接口/sys/tenant/deleteBatch
export const tenantdeleteBatch = (data) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/tenant/deleteBatch?ids=${data.ids}`,
  method: "DELETE",
  data
})
//查询接口
export const searchlist = (data) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/user/list?_t=1664442367&username=*${data.username}*&realname=*${data.realname}*&sex=${data.sex}&phone=*${data.phone}*&status=${data.status}&pageNo=${data.pageNo}&pageSize=${data.pageSize}`,
  methods: "get",
  data
})
//租户分配
export const sysDepartRolelist = (data) => requests({
  url: `/sys/position/list?_t=1665209354&column=createTime&order=desc&field=id,,name,code,rank_dictText&pageNo=1&pageSize=5`,
  methods: 'get',
  data
})
//租户列表/sys/tenant/list
export const tenantlist = (data) => requests({
  url: `/sys/tenant/list?pageNo=${data.pageNo}&pageSize=${data.pageSize}`,
  methods: 'get',
  data
})
//用户分配/sys/role/queryall
export const rolequeryall = (data) => requests({
  url: `/sys/role/queryall`,
  methods: 'get',
  data
})
//用户列表/sys/role/list
export const rolelist = (data) => requests({
  url: `/sys/role/list?roleName=${data.roleName}`,
  methods: "get",
  data
})
//用户列表添加/sys/role/add
export const roleadd = (data) => requests({
  url: `/sys/role/add`,
  method: "POST",
  data
})
export const useruserRoleList = (data) => requests({
  url: `/sys/user/userRoleList?pageNo=${data.pageNo}&pageSize=${data.pageSize}&roleId=${data.roleId}&username=${data.username}`,
  methods: "get",
  data
})
//树形控件数据/sys/role/queryTreeList
export const rolequeryTreeList = (data) => requests({
  url: `/sys/role/queryTreeList`,
  methods: "get",
  data
})
//树形控件仅保存/sys/permission/saveRolePermission
export const permissionsaveRolePermission = (data) => requests({
  url: `/sys/permission/saveRolePermission`,
  method: "POST",
  data
})
//树形控件选中接口sys/permission/queryRolePermission
export const permissionqueryRolePermission = (data) => requests({
  url: `/sys/permission/queryRolePermission?roleId=${data.roleId}`,
  methods: "get",
  data
})
//提交用户/sys/user/add
export const useradd = (data) => requests({
  url: `http://localhost:8080/jeecg-boot/sys/user/add`,
  method: 'post',
  data
})

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}
export const getUserList = () => requests({
  url: `/sys/sysDepartRole/list`,
  method: "get"
})
export const getWork = () => requests({
  url: '/sys/position/list',
  method: "get"
})

export function logout() {
  return requests({
    url: '/logout',
    method: 'post'
  })
}
/**
 * 获取验证图片 以及token
 *
 * @author Jax
 * @date 2021/1/22 00:00
 */
export function reqGet(data) {
  return requests({
    url: '/captcha/get',
    method: 'post',
    data
  })
}

/**
 * 滑动或者点选验证
 *
 * @author Jax
 * @date 2021/1/22 00:00
 */
export function reqCheck(data) {
  return requests({
    url: '/captcha/check',
    method: 'post',
    data
  })
}

export function getCaptchaOpen(parameter) {
  return requests({
    url: '/getCaptchaOpen',
    method: 'get',
    params: parameter
  })
}
// 
// 请求数据
export const mesTableData = () => requests(
  {
    url: `http://localhost:8080/jeecg-boot/sys/permission/list`,//请求的地址
    methods: "GET"
  }
)

// 增加表单数据
export const addMenuTableData = (data) => requests(
  {
    url: `http://localhost:8080/jeecg-boot/sys/permission/add`,//请求的地址
    methods: "POST",
    data
  }
)

// 删
export const delMenuData = (data) => requests(
  {
    url: `http://localhost:8080/jeecg-boot/sys/permission/delete?id=${data.id}`,//请求的地址
    methods: "DELETE",

  }
)
// 回收站数据
export const trashTabledata = () => requests(
  {
    url: `http://localhost:8080/jeecg-boot/sys/user/recycleBin`,//请求的地址
    method: "GET",
  }
)

// 回收站数据返回
export const trashDataBack = (data) => requests(
  {
    url: `http://localhost:8080/jeecg-boot/sys/user/putRecycleBin`,//请求的地址
    method: "PUT",
    data
  }
)

// 回收站彻底删除
export const trashDataDel = (data) => requests(
  {
    url: `http://localhost:8080/jeecg-boot/sys/user/deleteRecycleBin?userIds=${data.userIds}`,//请求的地址
    method: "DELETE",
  }
)
